<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title></title>
    <link href="/static/css/bootstrap.css" rel="stylesheet">
    <script type="text/javascript" src="/static/js/jquery-3.2.1.js"></script>
    <script src="/static/js/echarts.js"></script>
    <script>
        function del(id) {
            $.post(
                "/del",
                {id:id},
                function (msg) {
                    if(msg=="true"){
                        alert("删除成功");
                        location.reload();
                    }else{
                        alert("删除失败");
                    }
                }
            )
        }
        function toUpdate(id) {
            location.href="/toUpdate?id="+id;
        }
    </script>
</head>
<body>
<center>
<h1>列表页面</h1>
<form action="/list" method="post">
    生日区间:<input type="date" name="date1" value="<fmt:formatDate value='${userVo.date1}' pattern='yyyy-MM-dd'/>">
    -<input type="date" name="date2" value="<fmt:formatDate value='${userVo.date2}' pattern='yyyy-MM-dd'/>">
    <button type="submit">查询</button>
</form>
<table class="table">
    <tr>
        <td>序号</td>
        <td>性别</td>
        <td>手机号</td>
        <td>生日</td>
        <td>用户名</td>
        <td>密码</td>
        <td>操作</td>
    </tr>
    <c:forEach items="${pg.list}" var="li">
        <tr>
            <td>${li.id}</td>
            <td>
                ${li.sex.name}
            </td>
            <td>${li.telephone}</td>
            <td>
                <fmt:formatDate value="${li.birthday}" pattern="yyyy-MM-dd"></fmt:formatDate>
            </td>
            <td>${li.username}</td>
            <td>${li.password}</td>
            <td>
                <input type="button" value="删除" onclick="del(${li.id})">
                <input type="button" value="修改" onclick="toUpdate(${li.id})">
            </td>
        </tr>
    </c:forEach>
</table>
<jsp:include page="/static/common/pages.jsp"></jsp:include>
</center>
</body>
</html>
